%% here we calculate the jacobian and show the radial field depends only on distance cube inverse from the monopole

syms alpha beta phi H0 real
x=H0*cos(alpha)*cos(beta);
y=H0*cos(alpha)*sin(beta);
z=H0*sin(alpha)*cos(phi);
w=H0*sin(alpha)*sin(phi);

J=jacobian([x,y,z,w],[alpha,beta,phi,H0]);

%% plot the data
load('./data/Fig2A.mat') % metric tensor
H_MT=H_berry_curvature;
H_MT_err=H_berry_err;

load('./data/Fig2BS14.mat'); % Berry connection
H_BC=H_berry_curvature;
H_BC_err=H_berry_err;

alpha=linspace(0,90,9);
coeff=2./sin(alpha(2:end-1)/90*pi);

cc=[0.0549    0.2706    0.6275
    0.9020         0    0.0627
    0.0980    0.5412    0.1843
    0.8941    0.2314    0.5333
    0.9647    0.3294    0.0510
    0.0941    0.5294    0.9098
    0.5686    0.7490    0.1020
    0.9882    0.7098    0.0588
    0.1020    0.5686    0.4745];

figure
hold on
errorbar(alpha(2:end-1),H_MT(2:end-1).*coeff,H_MT_err(2:end-1).*coeff,'s','MarkerSize',12,'LineWidth',1.5,'Color',cc(1,:),'MarkerFaceColor',cc(1,:));
errorbar(alpha(2:end-1),H_BC(2:end-1).*coeff,H_BC_err(2:end-1).*coeff,'s','MarkerSize',12,'LineWidth',1.5,'Color',cc(2,:),'MarkerFaceColor',cc(2,:));
plot(alpha,ones(size(alpha)),'-','MarkerSize',4,'LineWidth',1.5,'Color',cc(3,:),'HandleVisibility','off');

% legend('Metric tensor experiment','Berry curvature experiment','Location','southeast')
lgd=legend('from $g_{\mu\nu}$','from $\mathcal{F}_{\mu\nu}$');
lgd.FontSize=18;
set(lgd,'Interpreter','latex','Location','southeast')

xlim([0,90])
ylim([0,1.5])
xlabel('\alpha (^o)','LineWidth',4);
ylabel('H_{xyzw}^\perp (1/{H_0^3})','LineWidth',4);
set(gca,'FontSize',18);
box off;
